//
//  PersonalCenterViewController.m
//  与你同游
//
//  Created by rimi on 15/10/15.
//  Copyright (c) 2015年 LiuCong. All rights reserved.
//

#import "PersonalCenterViewController.h"
#define IMAGE_NAME(X) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForAuxiliaryExecutable:(X)]]
@interface PersonalCenterViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UIButton *iconImageButton;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIButton *finishButton;
@property (nonatomic, strong) NSArray *array;
@property (nonatomic, strong) NSMutableArray *dataSouce;
@property (nonatomic, strong) UILabel *IndividualitySignatureLabel;
@property (nonatomic, strong) UITextView * details;
@property (nonatomic, strong) UIImageView *backView;
@end

@implementation PersonalCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initUserInterface];
    [self initUserDatasouce];
}
- (void)initUserInterface {
    [self initBackButton];
    [self initNavTitle:@"个人信息"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.backView];
    [self.view addSubview:self.iconImageButton];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.IndividualitySignatureLabel];
    [self.view addSubview:self.details];
    [self.view addSubview:self.finishButton];
    
}
- (void)initUserDatasouce {
   self.array =  @[@"昵称", @"性别", @"年龄"];

}

#pragma mark --UITableViewDataSource 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *indentifier = @"CELL";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UILabel *label = [[UILabel alloc] initWithFrame:flexibleFrame(CGRectMake(200, 15, 130, 30), NO)];
    label.text = @"哎哟不错哦";
    label.textAlignment = NSTextAlignmentRight;
    label.textColor = [UIColor colorWithWhite:0.636 alpha:1.000];
    [cell.contentView addSubview:label];
    cell.textLabel.text = self.array[indexPath.row];
    cell.textLabel.textColor = [UIColor colorWithWhite:0.402 alpha:1.000];
    return cell;

}
#pragma mark --警告框里确定按钮的处理
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    UITextField *tf=[alertView textFieldAtIndex:0];
    NSLog(@"%@", tf.text);
    if (buttonIndex == 1) {
        
        
    }
    
    
}

#pragma mark -- UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"请输入昵称" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消",nil];
        [alertview setAlertViewStyle:UIAlertViewStylePlainTextInput];
        [alertview show];
    }
    if (indexPath.row == 1) {
        
    }
    if (indexPath.row == 0) {
        
    }
    
    
    
}

#pragma mark --getter
- (UIButton *)iconImageButton {
    if (!_iconImageButton) {
        _iconImageButton = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = flexibleFrame(CGRectMake(0, 0, 100, 100), NO);
            button.center = flexibleCenter(CGPointMake(375 / 2, 150));
            [button setImage:[UIImage imageNamed:@"相机1.png"] forState:UIControlStateNormal];
//            button.backgroundColor = [UIColor colorWithRed:0.635 green:0.740 blue:0.674 alpha:1.000];
            button.layer.cornerRadius = 10;
            button;
        });
    }
    return  _iconImageButton;
}
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = ({
            UITableView *tableView = [[UITableView alloc] initWithFrame:flexibleFrame(CGRectMake(0, 240, 375, 300), NO) style:UITableViewStylePlain];
            tableView.dataSource = self;
            tableView.delegate = self;
            tableView.rowHeight = 60;
            tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
            tableView;
        });
        
    }
    return _tableView;

}
- (NSArray *)array {
    if (!_array) {
        _array = [NSArray array];
    }
    return _array;
}
- (NSMutableArray *)dataSouce {
    if (!_dataSouce) {
        _dataSouce = [NSMutableArray array];
    }
    return _dataSouce;
}

-(UILabel *)IndividualitySignatureLabel {
    if (!_IndividualitySignatureLabel) {
        _IndividualitySignatureLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 420, 90, 30)];
            label.text = @"个性签名:";
            label.textColor = [UIColor colorWithWhite:0.402 alpha:1.000];
            label.font = [UIFont systemFontOfSize:16];
            label;
        });
    }
    return _IndividualitySignatureLabel;
}
- (UITextView *)details {
    if (!_details) {
        _details = ({
            UITextView  * textView = [[UITextView alloc] init];
            textView.frame = flexibleFrame(CGRectMake(30, 460, 310, 80), NO);
            textView.backgroundColor = [UIColor clearColor];
            textView.layer.cornerRadius = 5;
            textView.layer.borderWidth = 1;
            textView.layer.borderColor = [UIColor colorWithWhite:0.665 alpha:1.000].CGColor;
            textView.font = [UIFont systemFontOfSize:18];
            textView;
        });
    }
    return _details;
}
- (UIButton *)finishButton {
    if (!_finishButton) {
        _finishButton = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = flexibleFrame(CGRectMake(0, 0, 310, 40), NO);
            button.center = flexibleCenter(CGPointMake(375 / 2, 590));
            button.layer.cornerRadius = 5;
            [button setTitle:@"完成修改" forState:UIControlStateNormal];
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            button.backgroundColor = THEMECOLOR;
            button;
        });
    }
    return _finishButton;

}

-(UIImageView *)backView {
    if (!_backView) {
        _backView = ({
            UIImageView *customBackgournd = [[UIImageView alloc] initWithImage:IMAGE_NAME(@"个人信息背景2.png")];
            customBackgournd.frame = flexibleFrame(CGRectMake(0, 54, 375, 250), NO);
            UIVisualEffectView *visualEfView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
            visualEfView.frame = flexibleFrame(CGRectMake(0, 0, 375, 250), NO);
            visualEfView.alpha = 0.8;
            [customBackgournd addSubview:visualEfView];
            customBackgournd;
        });
    }
    return _backView;
}


@end
